/*
 * @Author: tcosfish
 * @Date: 2022-08-05 10:15:17
 * @LastEditors: tcosfish
 * @LastEditTime: 2022-08-18 15:35:37
 * @FilePath: \loadFile\src\database\views\CostDetails.view.ts
 */

import { ViewColumn, ViewEntity } from "typeorm"

@ViewEntity({
  expression: `
  SELECT
    \`subject_balance\`.\`code\` AS \`code\`,
    \`subject_balance\`.\`name\` AS \`name\`,
    \`subject_balance\`.\`debit_amount\` AS \`debit_amount\`,
    \`subject_balance\`.\`credit_amount\` AS \`credit_amount\`
  FROM
    \`subject_balance\`
  WHERE (
      \`code\` like '6___%'
      or \`code\` like '2221.%'
    ) and (
      not \`debit_amount\` is null
      and not \`credit_amount\` is null
    )
  `,
})
export class CostDetailsView {
  @ViewColumn()
  code: string = ""

  @ViewColumn()
  name: string = ""

  @ViewColumn()
  debit_amount: string = ""

  @ViewColumn()
  credit_amount: string = ""
}
